// ValidationAspects
// Written by Mike Saunders
// Released under Microsoft Public License (Ms-PL)
using NUnit.Framework;
using ValidationAspects.Exceptions;
using ValidationAspects.Factories;
using ValidationAspects.Sdk;

namespace TestValidationAspects.Factories
{
	[TestFixture]
	public class TestNotNull
	{
		[Test]
		public void Test_NotNull()
		{
			IValidator<object> validator = new NotNull().Create<object>();

			Test.Throws<ValidateNotNullException>(() => validator.Invoke(null, new MockValidationContext()), new ValidateNotNullException().Message);
			validator.Invoke(new object(), new MockValidationContext());
		}

		[Test]
		public void Test_NotNull_for_ValureType()
		{
			IValidator<int> validator = new NotNull().Create<int>();

			validator.Invoke(123, new MockValidationContext());
		}

		[Test]
		public void Test_NotNull_for_Nullable_type()
		{
			IValidator<int?> validator = new NotNull().Create<int?>();

			Test.Throws<ValidateNotNullException>(() => validator.Invoke(null, new MockValidationContext()), new ValidateNotNullException().Message);
			validator.Invoke(123, new MockValidationContext());
		}
	}
}